/**
 *
 */
package de.cbf.cam.dsa.facet.weapon_ranged.persister.db4o.client;

import java.util.Map;

import org.eclipse.jface.preference.IPreferenceStore;

import de.cbf.cam.dsa.facet.weapon_ranged.FacetWeaponRanged;
import de.cbf.cam.dsa.facet.weapon_ranged.persister.db4o.client.act.ActivatorFacetWeaponRanged_Db4oClient;
import de.cbf.cam.dsa.facet.weapon_ranged.service.persister_interface.IServicePersister_FacetWeaponRanged;
import de.cbf.util.db.interfaces.exceptions.EntityLoadException;
import de.cbf.util.db.interfaces.exceptions.EntitySaveException;
import de.cbf.util.entity.facet.persistence.db4o.AbstractReflectiveElementPersisterDB4O;
import de.cbf.util.uuidheader.entities.UUIDReference;
import de.cbf.util.uuidheader.interfaces.IUUIDHeader;

/**
 * @author Nebelritter * 
 */
public class ServicePersister_FacetWeaponRanged_Db4o extends AbstractReflectiveElementPersisterDB4O implements IServicePersister_FacetWeaponRanged{

	public static final String NAME = "Facet:WeaponRanged:DB4O";
	
	/* (non-Javadoc)
	 * @see de.cbf.util.entity.facet.persistence.db4o.AbstractReflectiveElementPersisterDB4O#init()
	 */
	@Override
	protected void init() {		
		super.init();
		setDisplayName(NAME);
	}
	
	@Override
	protected IPreferenceStore getPreferenceStoreFromActivator() {
		return ActivatorFacetWeaponRanged_Db4oClient.getDefault().getPreferenceStore();
	}
	
	@Override
	protected Class<? extends IUUIDHeader> getPersistedClass() {
		return FacetWeaponRanged.class;
	}

	@Override
	public void persistFacetWeaponRanged(FacetWeaponRanged facet,Map<String, Object> options)
			throws EntitySaveException {
		persistElement(facet,options);		
	}

	@Override
	public FacetWeaponRanged loadFacetWeaponRanged(UUIDReference reference)
			throws EntityLoadException {
		IUUIDHeader element = loadElement(reference);		
		if (element instanceof FacetWeaponRanged) {
			FacetWeaponRanged facetTalent = (FacetWeaponRanged) element;
			return facetTalent;
		}
		throw new EntityLoadException("entity of wrong type(expected "+FacetWeaponRanged.class.getSimpleName()+"): "
				+element==null?"null":element.getClass().getSimpleName());	
	}

	
}
